<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@taglib prefix="s" uri="strutsTags"%>
<%@taglib prefix="ty" uri="/wyzzTags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<head>
	<base href="<%=basePath%>">
	<link href="resource/css/style.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="resource/js/hrm/profile.js"></script>
	<title>离职员工管理</title>
</head>
<body align="left">
	<s:component template="bodyhead">
		<s:param name="pagetitle" value="'离职员工管理'" />
	</s:component>
	<s:form id="empQuitManagement" name="empQuitManagement"
		action="empQuitManagement" namespace="/profile" method="POST">
		<input type="hidden" name="qemp.ids" id="ids" />
		<input type="hidden" name="id" id="delEmpId" />
		<table width="100%" class="formtable">
			<s:hidden id="operate" name="page.operate" />
			<s:hidden id="order" name="page.order" />
			<s:hidden id="page.currentPage" name="page.currentPage" />
			<tr>
				<td>
					<table width="100%">
						<tr>
							<s:textfield label="员工" id="employeeId" name="employeeId"
								size="16" maxlength="64" />
							<td align="right">
								组织单元:
							</td>
							<td>
								<s:orgselector id="orgselector1" name="departmentName"
									hiddenFieldName="departmentId" isShowDisable="show" />
							</td>
							<td align="right">
								离职种类:
							</td>
							<td>
								<s:select name="eqType" id="eqType" list="eqTypeMap"
									onchange="model.simple.changeSubSelect(this,'eqReason','eqTypeSubMap')" />
								原因:
								<select name="eqReason" id="eqReason" />
							</td>
						</tr>
						<tr>
							<s:textfield id="eqPermission" label="审批人" name="eqPermission"
								size="16" maxlength="64" />
							<s:textfield id="eqComments" label="备注" name="eqComments"
								size="16" maxlength="64" />
							<td align="right">
								离职时间:
							</td>
							<td>
								<s:textfield id="eqDate" name="eqDate" size="10" maxlength="10" />
								<img onclick="WdatePicker({el:'eqDate'})" class="dateimg"
									src="resource/js/My97DatePicker/skin/datePicker.gif">
								到
								<s:textfield id="eqDateTo" name="eqDateTo" size="10"
									maxlength="10" />
								<img onclick="WdatePicker({el:'eqDateTo'})" class="dateimg"
									src="resource/js/My97DatePicker/skin/datePicker.gif">
							</td>
						</tr>
					</table>
				</td>
				<td>
					<input title="[Alt+F]" accesskey="F" id="submit_button"
						class="button" type="submit" value="查询"
						onclick="document.getElementById('searchOrExport').value='';">
					<input title="[Alt+C]" accesskey="C" class="button" type="reset"
						value="重置" onclick="window.location='empQuitManagement.action'">
				</td>
			</tr>
		</table>

		<!-- 操作 -->
		<div class="operatediv">
			<span class="operatedivleft"> <input type="hidden"
					name="searchOrExport" id="searchOrExport" /> <s:hidden
					id="output-ommId" name="outmatchModelId" /> <s:hidden
					id="output-ioName" name="outputIoName" /> <ty:auth auths="101">
					<input class="button" type="button" onclick="batch('delete');"
						value="员工删除" />
					<input class="button" type="button" onclick="batch('rehab')"
						value="批量复职" />
				</ty:auth> <ty:auth auths="101,2 or 101,3">
					<input class="button" type="button" id="btnOutput" value="数据导出"
						onClick="document.getElementById('searchOrExport').value='export';document.getElementById('empQuitManagement').submit();" />
				</ty:auth> </span>
			<span class="operatedivright">本次查询共得到<s:property
					value="page.totalRows" />名员工记录</span>
		</div>

		<table cellpadding="0" cellspacing="0" width="100%" border="0"
			class="gridtableList">
			<tr>
				<ty:auth auths="101">
					<th align="center" width="3%">
						<input id="id_check_all" class="checkbox" type="checkbox"
							onclick="hrm.common.checkAllByName('quitemp.ids','id_check_all');"
							value="0">
					</th>
				</ty:auth>
				<th nowrap="nowrap">
					<a
						onclick="hrm.common.order_submit('empDistinctNo','empQuitManagement');">员工编号</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='empDistinctNo_img'>
				</th>
				<th nowrap="nowrap">
					<a
						onclick="hrm.common.order_submit('empName','empQuitManagement');">员工姓名</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='empName_img'>
				</th>
				<th nowrap="nowrap">
					<a
						onclick="hrm.common.order_submit('empDeptNo.departmentSortId','empQuitManagement');">部门</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='empDeptNo.departmentSortId_img'>
				</th>
				<th nowrap="nowrap">
					<a
						onclick="hrm.common.order_submit('empTerminateDate','empQuitManagement');">离职日期</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='empTerminateDate_img'>
				</th>
				<th nowrap="nowrap">
					<a
						onclick="hrm.common.order_submit('manager.empName','empQuitManagement');">审批人</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='manager.empName_img'>
				</th>
				<th nowrap="nowrap">
					<a
						onclick="hrm.common.order_submit('quit.eqType','empQuitManagement');">种类</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='quit.eqType_img'>
				</th>
				<th nowrap="nowrap">
					<a
						onclick="hrm.common.order_submit('quit.eqReason','empQuitManagement');">离职原因</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='quit.eqReason_img'>
				</th>
				<th nowrap="nowrap">
					<a
						onclick="hrm.common.order_submit('quit.erComments','empQuitManagement');">备注</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='quit.erComments_img'>
				</th>
				<th nowrap="nowrap">
					操作
				</th>
			</tr>
			<tbody>
				<s:if test="!quitList.isEmpty()">
					<s:iterator value="quitList" status="quitStatus">
						<tr>
							<td align="center" width="3%">
								<input name="quitemp.ids" class="checkbox" type="checkbox"
									value="<s:property value='id'/>" />
							</td>
							<td nowrap="nowrap">
								<a class="listViewTdLinkS1"
									href="profile/myInfo.action?empNo=<s:property value='id'/>&empName=<s:property value='empName'/>">
									<s:property value="empDistinctNo" /> </a>
							</td>
							<td nowrap="nowrap">
								<s:property value="empName" />
							</td>
							<td nowrap="nowrap">
								<s:property value="empDeptNo.departmentName" />
							</td>
							<td nowrap="nowrap" align="center">
								<s:property value="empTerminateDate" />
							</td>
							<td nowrap="nowrap">
								<s:property value="quit.eqPermission.empName" />
							</td>
							<s:if test="quit!=null">
								<td nowrap="nowrap">
									<s:if test="quit.eqType==0">辞职</s:if>
									<s:if test="quit.eqType==1">复职</s:if>
									<s:if test="quit.eqType==2">停薪留职</s:if>
									<s:if test="quit.eqType==3">退休</s:if>
									<s:if test="quit.eqType==4">辞退</s:if>
									<s:if test="quit.eqType==5">合同到期</s:if>
									<s:if test="quit.eqType==6">其他</s:if>
								</td>
								<td nowrap="nowrap">
									<s:property value="quit.eqReason" />
								</td>
								<td>
									<s:property value="quit.erComments" />
								</td>
							</s:if>
							<s:else>
								<td nowrap="nowrap">
									&nbsp;
								</td>
								<td nowrap="nowrap">
									&nbsp;
								</td>
								<td>
									&nbsp;
								</td>
							</s:else>
							<td align="center" nowrap="nowrap" colspan="2">
								<img
									onclick="hrm.profile.showInfoCardInfo('<s:property value='id'/>');"
									alt="员工资料卡" title="员工资料卡" border='0' class="urlimg"
									src="resource/images/Search.gif" />
								<ty:auth auths="101">
									<img onclick="deleteEmp('<s:property value='id'/>');" alt="删除"
										title="删除" class="urlimg" src="resource/images/delete.gif" />
								</ty:auth>
							</td>
						</tr>
					</s:iterator>
				</s:if>
				<s:else>
					<tr>
						<td colspan="8" align="center">
							无相关记录！
						</td>
					</tr>
				</s:else>
			</tbody>
		</table>
		<s:pager end="page.end" pageNo="page.currentPage"
			totalRows="page.totalRows" totalPages="page.totalPages"
			formId="empQuitManagement" start="page.start" />
	</s:form>
	<!-- 批量复职 -->
	<div id="dlgReturnDiv" title="批量复职" class="prompt_div_inline"
		style="width: 420;">
		<table cellpadding="0" border="0">
			<tr>
				<td>
					复职日期
					<span class="required">*</span>:
				</td>
				<td>
					<s:textfield id="joinDate" name="qemp.empJoinDate" required="true"
						size="10" maxlength="10" />
					<img onclick="WdatePicker({el:'joinDate'})" class="dateimg"
						src="resource/js/My97DatePicker/skin/datePicker.gif">
				</td>
			</tr>
			<tr>
				<td>
					复职种类
					<span class="required">*</span>:
				</td>
				<td>
					<s:select name="empquit.eqType" id="eqRType" list="eqRTypeMap"
						onchange="model.simple.changeSubSelect(this,'empquit.eqReason_id','eqTypeSubMapR')">
					</s:select>
				</td>
			</tr>
			<tr>
				<td>
					复职审批人
					<span class="required">*</span>:
				</td>
				<td>
					<input id="empManagerName" readonly="readonly">
					<input type="hidden" name="empquit.eqPermission.id"
						id="empManagerId" />
					<img src="resource/images/search_icon.gif" style="CURSOR: pointer"
						onclick="showChooseEmpDiv(1,1,'','empManagerName','empManagerId');"
						alt='点击图标选择经理' />
				</td>
			</tr>
			<tr>
				<td>
					复职原因
					<span class="required">*</span>:
				</td>
				<td>
					<select name="empquit.eqReason" id="empquit.eqReason_id"></select>
				</td>
			</tr>
			<tr>
				<td>
					复职职位
					<span class="required">*</span>:
				</td>
				<td>
					<div>
						<s:hidden id="chang_dept_id" name="chang_dept_id" />
						<s:hidden id="chang_dept_name" name="chang_dept_name" />
						<s:hidden id="positionId" name="empquit.position.id" />
						<s:hidden id="empPBName"
							name="empquit.position.positionPbId.pbName" />
						<input type="text" id="chang_dept_name-empPBName"
							name="empquit.position.positionPbId.pbName" class="selecttext"
							readonly="readonly" size="26" />
						<img
							onclick="showPostionTree('empPBName', 'positionId', 'chang_dept_name', 'chang_dept_id');"
							id="showdiv" class="selectimg"
							src="resource/images/select_button.BMP">
					</div>
				</td>
			</tr>
			<tr>
				<td>
					备注:
				</td>
				<td>
					<textarea name="empquit.erComments" rows="8" cols="40"
						onkeyup="if(this.value.length>255){this.value=this.value.substring(0, 255);}"></textarea>
				</td>
			</tr>
			<tr>
				<td colspan="2" class="prompt_div_bottom">
					<!-- <input type="hidden" value='<s:property value="#session.curr_oper_no"/>' name="employeeId"> -->
					<input id="eqAddbtn" class="button" type="button"
						onclick="doRehab();" ; value="复职" />
					<input class="button" type="button" value="取消"
						onclick="hrm.common.closeDialog('dlgReturnDiv');" />
				</td>
			</tr>
		</table>
	</div>
	<script type="text/javascript">
//初始化复职下拉框
eqRTypeSubMap={};
<s:iterator value="eqRReasonMap" id="topEntrySetR">
	eqRTypeSubMap['<s:property value="#topEntrySetR.key"/>']={};
	<s:iterator value="#topEntrySetR.value" status="index" id="secEntrySetR">
		<s:if test="#secEntrySetR.key.length()==0">
		eqRTypeSubMap['<s:property value="#topEntrySetR.key"/>']['']='<s:property value="#secEntrySetR.value"/>';
		</s:if>
		<s:else>
			eqRTypeSubMap['<s:property value="#topEntrySetR.key"/>']['<s:property value="#secEntrySetR.value"/>']='<s:property value="#secEntrySetR.value"/>';
		</s:else>
	</s:iterator>
</s:iterator>
model.simple.changeSubSelect('eqRType','empquit.eqReason_id','eqRTypeSubMap','<s:property value="quit.eqReason"/>');

//初始化离职下拉框
eqTypeSubMap={};
<s:iterator value="eqReasonMap" id="topEntrySet">
	eqTypeSubMap['<s:property value="#topEntrySet.key"/>']={};
	<s:iterator value="#topEntrySet.value" status="index" id="secEntrySet">
		<s:if test="#secEntrySet.key.length()==0">
			eqTypeSubMap['<s:property value="#topEntrySet.key"/>']['']='<s:property value="#secEntrySet.value"/>';
		</s:if>
		<s:else>
			eqTypeSubMap['<s:property value="#topEntrySet.key"/>']['<s:property value="#secEntrySet.value"/>']='<s:property value="#secEntrySet.value"/>';
		</s:else>
	</s:iterator>
</s:iterator>
model.simple.changeSubSelect('eqType','eqReason','eqTypeSubMap','<s:property value="quit.eqReason"/>');
//删除离职员工
function deleteEmp(id){
	if(confirm("确定要删除吗？")){
		document.getElementById('delEmpId').value=id;
		document.getElementById('empQuitManagement').action="profile/deleteEmp.action";
		document.getElementById('searchOrExport').value = "";
		document.getElementById('empQuitManagement').submit();
	}
}
//批量删除/复职
function batch(operate){
	var checkBoxs=document.getElementsByName('quitemp.ids');
	var flag=0;
	error="";
	var ids = "";
	for(var i=0;i<checkBoxs.length;i++){
		if(checkBoxs[i].checked==true){
			flag=1;
			ids+= checkBoxs[i].value;
			if(i != checkBoxs.length - 1){
    	   		ids+= ",";
			}
		}
	}
	if(flag==0){
		error="请至少选择一个员工！";
	}
	if(error.length>1){
		alert(error);
		return ;
	}
	if('delete' == operate){
		if (confirm("您确定要删除吗？")){
			document.getElementById('operate').value=operate;
			document.getElementById('ids').value = ids;
			document.getElementById('empQuitManagement').action="profile/batchDeleteEmp.action";
			document.getElementById('searchOrExport').value = "";
			document.getElementById('empQuitManagement').submit();
		}
	}
	else if("rehab" == operate){
		document.getElementById('joinDate').value = (new Date()).toHRMDateString();
		hrm.common.openDialog('dlgReturnDiv','empQuitManagement');
	}
}
//复职
function doRehab(){
	checkBoxs=document.getElementsByName('quitemp.ids');
	var flag=0;
	error="";
	var ids = "";
	for(var i=0;i<checkBoxs.length;i++){
		if(checkBoxs[i].checked&&checkBoxs[i].checked==true){
			flag=1;
			ids+= checkBoxs[i].value;
			if(i != checkBoxs.length - 1){
				ids+= ",";
			}
		}
	}
	if(flag==0){
		error="请至少选择一个员工！";
	}
	if(error.length>1){
		alert(error);
		return ;
	}
	if(!hrm.common.isDate(document.getElementById('joinDate').value)) {
		alert('复职日期不能为空或日期格式不正确！');
		return;
	}
	if(hrm.common.isNull(document.getElementById('empManagerName').value)){
		alert("复职审批人不能为空！");
		return;
	}
	if(hrm.common.isNull(document.getElementById('empquit.eqReason_id').value)){
		alert("复职原因不能为空！");
		return;
	}
	if(hrm.common.isNull(document.getElementById('chang_dept_name-empPBName').value)){
		alert("复职组织单元不能为空！");
		return;
	}
	ids = ids.trim();
	if(',' == ids.charAt(ids.length-1)){
		ids = ids.substring(0,ids.length-1);
	}
	document.getElementById('ids').value = ids;
	document.getElementById('empQuitManagement').action="profile/batchRehabEmp.action";
	document.getElementById('searchOrExport').value = "";
	document.getElementById('empQuitManagement').submit();
}
hrm.common.check_order();
hrm.common.initDialog('dlgReturnDiv');
</script>
	<%@ include file="search_emp_div.jsp"%>
	<jsp:include flush="true" page="../io/div_omm_select.jsp"></jsp:include>
	<jsp:include flush="true" page="position_choose_div.jsp"></jsp:include>
</body>